﻿#ifndef LOCAL_SOCKET_H
#define LOCAL_SOCKET_H
#pragma execution_character_set("utf-8")
#include <QJsonDocument>
#include <QJsonObject>
#include <QObject>
#include <QLocalSocket>
#include <QDataStream>
#include <enum_type.h>
class local_socket : public QLocalSocket
{
    Q_OBJECT
public:
    local_socket(qintptr  socketDescriptor);
    ~local_socket();
    qintptr  socketDescriptor;
    bool localSocket_init();
    void send_message(QString id,QString type,QString data);
private:
    QByteArray receive_data;                                    //接受的信息
    qint64     receive_datasize=0;                              //接受信息大小
    qint32 feature=19960108;                                    //tcp包标识符
    void analyse_data();                                        //拆包
    void process_data(QByteArray data);                         //处理数据
    QByteArray json_pack(QString id,QString type,QString data); //json封装
    QStringList json_analyse(QByteArray data);                  //json解析
    void senddata(QByteArray data);
private slots:
    void receive();
    void l_socketSend(QString id, QString type, QString data, local_socket *socket,emit_type e_type,QString socketType); //本地socket发送
    void disconnect_Allsocket();
signals:
    void reply_data(QString id,QString type,QString data);      //转发来自计算进程的信息

};

#endif // LOCAL_SOCKET_H
